package br.com.atibrasil.model;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@NamedQueries({ 
	@NamedQuery(name = "MenuGrupo.findByVisibility", query = "SELECT m FROM MenuGrupo m WHERE m.visivel = true and m.menu.id = ?1 order by m.ordem")
})
@Table(name="menu_grupo")
public class MenuGrupo implements Serializable{
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private int id;
	
	private String descricao;
	
	private int ordem;
	
	private boolean visivel;
	
	@ManyToOne
	@JoinColumn(name="id_menu")
	private Menu menu;
	
	@OneToMany(mappedBy="grupo", fetch = FetchType.EAGER ,orphanRemoval = true)
	private List<MenuItem> itens;
	

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getDescricao() {
		return descricao;
	}
	
	public Menu getMenu() {
		return menu;
	}

	public void setMenu(Menu menu) {
		this.menu = menu;
	}

	public void setDescricao(String descricao) {
		this.descricao = descricao;
	}	

	public int getOrdem() {
		return ordem;
	}

	public void setOrdem(int ordem) {
		this.ordem = ordem;
	}

	public boolean isVisivel() {
		return visivel;
	}

	public void setVisivel(boolean visivel) {
		this.visivel = visivel;
	}

	public List<MenuItem> getItens() {
		return itens;
	}

	public void setItens(List<MenuItem> itens) {
		this.itens = itens;
	}
	
	

}
